﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;
using System.Data;
using System.Configuration;

namespace ZLDC.Estate.CM
{
    public partial class Customer : _PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) 
            {
                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(occupation, false, "职业");
                occupation.Items.Insert(0, "请选择");
              
                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(customerClass, false, "等级");
                customerClass.Items.Insert(0, "请选择");
                
                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(infoFrom, false, "客源来源");
                infoFrom.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(buyingMotive, false, "购买动机");
                buyingMotive.Items.Insert(0, "请选择");
                
                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(tradetype, false, "交易(客)");
                tradetype.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadMarkParamType(status, false, "客源状态");
                status.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(payType, false, "付佣方式");
                payType.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(type, false, "类型");
                type.Items.Insert(0, "请选择");


                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(houseStyle, false, "样式");
                houseStyle.Items.Insert(0, "请选择");



                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(fitment, false, "装修");
                fitment.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadIDParamType(usage, false, "用途");
                usage.Items.Insert(0, "请选择");

                ZLDC.Topo.BLL.Estate.SystemParamBLL.LoadParamType(sDirect, true, "朝向");
                sDirect.Items.Insert(0, "请选择");

                markname .Value = this.info.m_sUserName;
                markdept.Value = this.info.m_sDeptName;

                LoadCity2();
               
                int typeid = _Request.GetInt("typeid", 0);   // 2 表示转介客预登
                if (typeid == 2)
                    AddDeptTree();
            }
        }

        /// <summary>
        /// 加载城区
        /// </summary>
        private void LoadCity2()
        {
            ZLDC.Topo.BLL.Estate.AreaBLL.LoadCity(Sdame, 1);
            ListItem item1 = new ListItem("全部", "0");
            Sdame.Items.Insert(0, item1);
           
        }

        //private void LoadCity1() 
        //{
        //    _Database db = new _Database("estate");
        //    DataTable dt = ZLDC.DAL.Estate.AreaDAL.p_area_listall_table(1, db);
        //    string  strarr="";
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        strarr += "<input id='cbDid" + i + "' name='sldname' value='" + dt.Rows[i]["id"] + "' type='checkbox'/>" + dt.Rows[i]["name"].ToString() + "<input id='cbDname" + i + "'  value='" + dt.Rows[i]["name"] + "' type='hidden'/>";
        //    }
        //    divdname.InnerHtml = strarr;
        //}


        /// <summary>
        /// 选择部门树形菜单
        /// </summary>
        private void AddDeptTree()
        {
            string sTopDept = this.info.m_sDeptID;//默认取表中第一行为最上层部门
            string deptid_list = CacheUtility.Cache_GetAllChildDept(this.info.m_sDeptID);

            sTopDept = ConfigurationSettings.AppSettings["SalesDepartment"].ToString().Trim();//最上层部门

            ZLDC.Topo.BLL.Estate.DeptTree zdt = new ZLDC.Topo.BLL.Estate.DeptTree(sTopDept, deptid_list);
            ltlDeptTree.Text = zdt.GetZlhqDept();
        }

    }
}
